package com.example.article.controller;

import com.example.article.service.ArticleHomeService;
import com.usian.model.article.dtos.ApArticleDto;
import com.usian.model.article.dtos.ArticleHomeDto;
import com.usian.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 文章主页控制器
 *
 */
@RestController
@RequestMapping("app/article/v1")
public class ArticleHomeController {
    
    @Autowired
    ArticleHomeService articleHomeService;
    
    /**
     * 加载首页
     *
     * @param articleHomeDto 美联社文章dto
     * @return {@code ResponseResult}
     */
    @PostMapping("/load")
    public ResponseResult load(@RequestBody ArticleHomeDto articleHomeDto) {
        return articleHomeService.load(articleHomeDto);
    }
    
    /**
     * 加载新文章
     *
     * @param articleHomeDto 家dto条
     * @return {@code ResponseResult}
     */
    @PostMapping("/load_new")
    public ResponseResult loadNew(@RequestBody ArticleHomeDto articleHomeDto) {
        return articleHomeService.load(articleHomeDto);
    }
    
    /**
     * 加载更多文章
     *
     * @param articleHomeDto 家dto条
     * @return {@code ResponseResult}
     */
    @PostMapping("/load_more")
    public ResponseResult loadMore(@RequestBody ArticleHomeDto articleHomeDto) {
        
        return articleHomeService.load(articleHomeDto);
    }
    
    /**
     * 得到文章详情
     *
     * @param id id
     * @return {@code ResponseResult}
     */
    @GetMapping("get_article_detail")
    public ResponseResult getArticleDetail(@RequestParam Long id){
        return articleHomeService.getArticleDetail(id);
    }
    
}
